package com.zyc.service.Impl;

import com.zyc.mapper.EnterpriseMapper;
import com.zyc.mapper.UserMapper;
import com.zyc.pojo.EnterprisePojo;
import com.zyc.pojo.UserPojo;
import com.zyc.service.EnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EnterpriseServiceImpl implements EnterpriseService {
    @Autowired(required = false)
    private EnterpriseMapper enterpriseMapper;
    @Override
    public List<EnterprisePojo> findAllEnterprises() {
        return enterpriseMapper.findAllEnterprises();
    }



    @Override
    public EnterprisePojo findEnterpriseByID(String id) {
        return enterpriseMapper.findEnterpriseByID(id);
    }



    @Override
    public int insertEnterprise(EnterprisePojo enterprisePojo) {
        return enterpriseMapper.insertEnterprise(enterprisePojo);
    }



    @Override
    public int deleteEnterpriseByID(String id) {
        return enterpriseMapper.deleteEnterpriseByID(id);
    }

    @Override
    public int updateEnterprise(EnterprisePojo enterprisePojo) {
        return enterpriseMapper.updateEnterprise(enterprisePojo);
    }

    @Override
    public List<EnterprisePojo> findEnterpriseByStr(String searchStr) {
        return enterpriseMapper.findEnterpriseByStr(searchStr);
    }


    @Override
    public int deleteEnterprises(String[] ids) {
        int count= 0;
        for(String id:ids)
        {
            count+=enterpriseMapper.deleteEnterpriseByID(id);//逐个删除图书
        }
        return count;//返回删除总数
    }
}
